home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / UCRASM25.ARJ / PUTISIZE.ASM < prev    next >
Assembly Source File  |  1991-10-12  |  2KB  |  86 lines

  1. StdGrp        group    stdlib,stddata
  2. stddata        segment    para public 'sldata'
  3. stddata        ends
  4. ;
  5. stdlib        segment    para public 'slcode'
  6.         assume    cs:stdgrp
  7.         extrn   sl_putc:far, sl_ISize:far, sl_USize:far
  8. ;
  9. ; Puti prints the value in AX as a signed integer value.  CX contains the
  10. ; minimum field width for the number.
  11. ;
  12.         public  sl_PutiSize
  13. sl_PutiSize     proc    far
  14.         push    ax
  15.         push    bx
  16.         push    cx
  17.         push    dx
  18.         push    ax
  19.         call    sl_ISize
  20.         sub     cx, ax
  21.         js      NoSpaces
  22.         jcxz    NoSpaces
  23.         mov     al, ' '
  24. SpcsLoop:       call    sl_Putc
  25.         loop    SpcsLoop
  26. NoSpaces:       pop     ax
  27.         cmp    ax, 0
  28.         jge    Doit
  29.         push    ax
  30.         mov    al, '-'
  31.         call    sl_Putc
  32.         pop    ax
  33.         neg    ax
  34. ;
  35. DoIt:        call    puti2
  36.         pop     dx
  37.         pop     cx
  38.         pop     bx
  39.         pop     ax
  40.         ret
  41. sl_PutiSize     endp
  42. ;
  43. ; Putu prints the value in AX as an unsigned integer value.
  44. ;
  45.         public  sl_PutUSize
  46. sl_PutUSize     proc    far
  47.         push    ax
  48.         push    bx
  49.         push    cx
  50.         push    dx
  51.         push    ax
  52.         call    sl_USize
  53.         sub     cx, ax
  54.         js      NoUSpaces
  55.         jcxz    NoUSpaces
  56.         mov     al, ' '
  57. SpcsLp2:        call    sl_Putc
  58.         loop    SpcsLp2
  59. NoUSpaces:      pop     ax
  60.         call    PutI2
  61.         pop     dx
  62.         pop     cx
  63.         pop     bx
  64.         pop     ax
  65.         ret
  66. sl_PutUSize     endp
  67. ;
  68. ; PutI2- Recursive routine to actually print the value in AX as an integer.
  69. ;
  70. Puti2        proc    near
  71.         mov    bx, 10
  72.         xor    dx, dx
  73.         div    bx
  74.         or    ax, ax        ;See if ax=0
  75.         jz    Done
  76.         push    dx
  77.         call    Puti2
  78.         pop    dx
  79. Done:        mov    al, dl
  80.         or    al, '0'
  81.         call    sl_Putc
  82.         ret
  83. PutI2        endp
  84. stdlib        ends
  85.         end
  86.